<?php $form = $this->beginWidget('CActiveForm', array(
				'id'=>'category-form',		
)); ?>
	<p>
		<label>上级分类：</label>
		<?php echo $form->dropDownList($model, 'category_pid', Category::getCategorySelect(Category::getCategoryTree(0)), array('class'=>'small-input','prompt'=>'顶级分类')); ?>
	</p>
	<p>
		<label>分类模型：</label>
		<?php echo $form->dropDownList($model, 'model_id', CHtml::listData(Mod::model()->findAll(), 'model_id', 'model_name'), array('class'=>'small-input', 'onchange'=>'UrlInput(this)')); ?>
	</p>
	<p>
       <label>分类名称：</label>
       <?php echo $form->textField($model, 'category_name', array('class'=>'text-input small-input')); ?>
    </p>
    <p id="category_url" style="display:none">
        <label>外部链接地址：</label>
        <?php echo $form->textField($model, 'category_url', array('class'=>'text-input small-input')); ?>
    </p>
    <p>
		<label>分类排序：</label>
        <?php echo $form->textField($model, 'category_position', array('class'=>'text-input')); ?>
    </p>
    <p>
    	<?php echo CHtml::submitButton('提交', array('class'=>'button')) ?>
    	<?php echo $model->isNewRecord?'':CHtml::button('返回', array('class'=>'button', 'onclick'=>'history.back()')); ?>
    </p>
<?php $this->endWidget(); ?>
<script>
function UrlInput(obj)
{
	urlObj = document.getElementById("category_url");
	if (obj.value == 3)
	{
		urlObj.style.display = "block";
	}else{
		urlObj.style.display = "none";
	}
}
$(function(){
	if ("<?php echo $model->model_id; ?>" == 3)
	{
		$("#category_url").show();
	}else{
		$("#category_url input").val("");
	}
});
</script>